package com.ruoyi.project.system.device.pdf;

import java.awt.Color;
import java.io.File;

import tanling.matplot3d.app.facade.Matplot3D4JMgr;
import tanling.matplot3d.app.facade.legend.KeyLabelLegend;
import tanling.matplot3d.app.facade.processor.BarProcessor;

public class ThreeBarsDemo {
	public static void main(String[] args) throws Exception {

		BarProcessor processor = new BarProcessor();

		Matplot3D4JMgr mgr = new Matplot3D4JMgr(processor);

		// ===========================================
		// 在此准备数据
		// 每组数据在一个或多个二维数组中，数组中表示柱体高度（标1表示组号，相同组号同颜色；下标2表示同组中的不同列）
		// prepare your data here

		Double[][] ds1 = new Double[][] { { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 },
				{ 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 }, { 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 } };

		Color c1 = Color.RED;
		Color c2 = Color.GREEN;
		Color c3 = new Color(80, 80, 255);

		Color[][] colors = new Color[][] { { c1, c1, c1, c1, c1, c1, c1, c1 }, { c2, c2, c2, c2, c2, c2, c2, c2 },
				{ c3, c3, c3, c3, c3, c3, c3, c3 } };

		Color ce = Color.BLACK;

		Color[][] ecolors = new Color[][] { { ce, ce, ce, ce, ce, ce, ce, ce }, { ce, ce, ce, ce, ce, ce, ce, ce },
				{ ce, ce, ce, ce, ce, ce, ce, ce } };
		

		processor.addData("项目1", ds1,colors,ecolors);

		// =========================================

		processor.setBarWidthX(2);
		processor.setBarWidthY(2);

		processor.setxSpace(0.2);
		processor.setySpace(1);
		processor.setSpaceInBundle(0.3);

		//自定义标签图例面板
		KeyLabelLegend legend = new KeyLabelLegend();
		legend.put("项目A", c1);
		legend.put("项目B", c2);
		legend.put("项目C", c3);

		mgr.addLegend(legend);

		mgr.setScaleZ(1.5);
		mgr.setScaleX(1.3);

		mgr.setTitle("柱状图");

		mgr.setElevation(0.2);
		mgr.setAzimuth(2.2);

		mgr.setOutlineAntiAliasing(true);//可以关闭外廓反锯齿

//		mgr.show();
		File file = new File("D:\\exportPdf\\bars.png");
		mgr.saveImage(file, 200,200);
	}

}
